package com.effectiv.gooruda.rest.api.controller;

import org.springframework.social.facebook.api.Event;
import org.springframework.social.facebook.api.EventInvitee;

import org.springframework.social.facebook.api.Facebook;
import org.springframework.social.facebook.api.ImageType;
import org.springframework.social.facebook.api.Invitation;
import org.springframework.social.facebook.api.PagedList;
import org.springframework.social.facebook.api.PagingParameters;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/facebook/event")
public class FacebookEventOperationsController  {

	@RequestMapping(value="/acceptinvitation/{eventId}", method=RequestMethod.POST)
	public void acceptInvitation(String eventId, Facebook facebook) {
		facebook.eventOperations().acceptInvitation(eventId);
	}

	@RequestMapping(value="/createevent/{name}/{startTime}/{endTime}", method=RequestMethod.POST)
	public String createEvent(String name, String startTime, String endTime, Facebook facebook) {
		return facebook.eventOperations().createEvent(name, startTime, endTime);
	}

	@RequestMapping(value="/declineinvitation/{eventId}", method=RequestMethod.POST)
	public void declineInvitation(String eventId, Facebook facebook) {
		facebook.eventOperations().declineInvitation(eventId);
	}

	@RequestMapping(value="/deleteevent/{eventId}", method=RequestMethod.DELETE)
	public void deleteEvent(String eventId, Facebook facebook) {
		facebook.eventOperations().deleteEvent(eventId);
	}

	@RequestMapping(value="/getattending/{eventId}", method=RequestMethod.GET)
	public PagedList<EventInvitee> getAttending(String eventId, Facebook facebook) {
		return facebook.eventOperations().getAttending(eventId);
	}

	@RequestMapping(value="/getdeclined/{eventId}", method=RequestMethod.GET)
	public PagedList<EventInvitee> getDeclined(String eventId, Facebook facebook) {
		return facebook.eventOperations().getDeclined(eventId);
	}

	@RequestMapping(value="/getevent/{eventId}", method=RequestMethod.GET)
	public Event getEvent(String eventId, Facebook facebook) {
		return facebook.eventOperations().getEvent(eventId);
	}

	@RequestMapping(value="/geteventimage/{eventId}", method=RequestMethod.GET)
	public byte[] getEventImage(String eventId, Facebook facebook) {
		return facebook.eventOperations().getEventImage(eventId);
	}

	@RequestMapping(value="/geteventimage/{eventId}/{imageType}", method=RequestMethod.GET)
	public byte[] getEventImage(String eventId, ImageType imageType, Facebook facebook) {
		return facebook.eventOperations().getEventImage(eventId, imageType);
	}
	
	@RequestMapping(value="/getinvitations", method=RequestMethod.GET)
	public PagedList<Invitation> getInvitations(PagingParameters pagedListParameters, Facebook facebook) {
		return facebook.eventOperations().getInvitations(pagedListParameters);
	}

	@RequestMapping(value="/getinvitations/{userId}", method=RequestMethod.GET)
	public PagedList<Invitation> getInvitations(String userId,
			PagingParameters pagedListParameters, Facebook facebook) {
		return facebook.eventOperations().getInvitations(userId, pagedListParameters);
	}

	@RequestMapping(value="/getinvited/{eventId}", method=RequestMethod.GET)
	public PagedList<EventInvitee> getInvited(String eventId, Facebook facebook) {
		return facebook.eventOperations().getInvited(eventId);
	}

	@RequestMapping(value="/getmaybeattending/{eventId}", method=RequestMethod.GET)
	public PagedList<EventInvitee> getMaybeAttending(String eventId, Facebook facebook) {
		return facebook.eventOperations().getMaybeAttending(eventId);
	}

	@RequestMapping(value="/getnoreplies/{eventId}", method=RequestMethod.GET)
	public PagedList<EventInvitee> getNoReplies(String eventId, Facebook facebook) {
		return facebook.eventOperations().getNoReplies(eventId);
	}

	@RequestMapping(value="/maybeinvitation/{eventId}", method=RequestMethod.POST)
	public void maybeInvitation(String eventId, Facebook facebook) {
		facebook.eventOperations().maybeInvitation(eventId);
	}

	@RequestMapping(value="/search/{query}", method=RequestMethod.POST)
	public PagedList<Event> search(String query, PagingParameters pagedListParameters, Facebook facebook) {
		return facebook.eventOperations().search(query, pagedListParameters);
	}

	
}
